<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.8.0">
    

    

    



    <meta charset="utf-8">
    
    
    
    
    <title>主成分分析（PCA） | 路漫漫其修远兮，吾将上下而求索</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    <meta name="theme-color" content="#3F51B5">
    
    
    <meta name="keywords" content="机器学习">
    <meta name="description" content="1. 主成分分析优点：降低数据的复杂性，识别最重要的多个特征。 缺点：不一定需要，且可能损失有用信息。 使用数据类型：数值型数据">
<meta name="keywords" content="机器学习">
<meta property="og:type" content="article">
<meta property="og:title" content="主成分分析（PCA）">
<meta property="og:url" content="https://wgs666.github.io/2019/06/04/pca/index.html">
<meta property="og:site_name" content="路漫漫其修远兮，吾将上下而求索">
<meta property="og:description" content="1. 主成分分析优点：降低数据的复杂性，识别最重要的多个特征。 缺点：不一定需要，且可能损失有用信息。 使用数据类型：数值型数据">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="https://wgs666.github.io/assets/pca/Figure_1.png">
<meta property="og:updated_time" content="2019-06-04T16:01:38.304Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="主成分分析（PCA）">
<meta name="twitter:description" content="1. 主成分分析优点：降低数据的复杂性，识别最重要的多个特征。 缺点：不一定需要，且可能损失有用信息。 使用数据类型：数值型数据">
<meta name="twitter:image" content="https://wgs666.github.io/assets/pca/Figure_1.png">
    
        <link rel="alternate" type="application/atom+xml" title="路漫漫其修远兮，吾将上下而求索" href="../../../../atom.xml">
    
    <link rel="shortcut icon" href="../../../../img/favicon.ico">
    <link rel="stylesheet" href="../../../../css/style.css?v=1.7.2">
    <link href="/css/prism/prism-tomorrow-night.css" rel="stylesheet">
    <script>window.lazyScripts=[]</script>

    <!-- custom head -->
    

</head>

<body>
    <div id="loading" class="active"></div>

    <aside id="menu" class="hide">
  <div class="inner flex-row-vertical">
    <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menu-off">
        <i class="icon icon-lg icon-list-ul"></i>
    </a>
    <div class="brand-wrap" style="background-image:url(../../../../img/back_blue.png)">
      <div class="brand" align="center">
        <a href="../../../../index.html" class="avatar waves-effect waves-circle waves-light">
          <img src="../../../../img/wgs.jpg">
        </a>
        <hgroup class="introduce">
          <h5 class="nickname">Guangsheng Wu <br>吴光生</h5>
          <a href="mailto:undefined" class="mail">
        </a></hgroup>
      </div>
    </div>
    <div class="scroll-wrap flex-col">
      <ul class="nav">
        
            <li class="waves-block waves-effect">
              <a href="../../../../index.html">
                <i class="icon icon-lg icon-home"></i>
                主页
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="../../../../archives/">
                <i class="icon icon-lg icon-archives"></i>
                归档
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="../../../../categories/">
                <i class="icon icon-lg icon-th-list"></i>
                分类
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="../../../../tags/">
                <i class="icon icon-lg icon-tags"></i>
                标签
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://github.com/wgs666">
                <i class="icon icon-lg icon-github"></i>
                代码
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="../../../../about/">
                <i class="icon icon-lg icon-info-circle"></i>
                关于
              </a>
            </li>
        
      </ul>
    </div>
  </div>
</aside>

    <main id="main">
        <header class="top-header" id="header">
    <div class="flex-row">
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light on" id="menu-toggle">
          <i class="icon icon-lg icon-navicon"></i>
        </a>
        <div class="flex-col header-title ellipsis">主成分分析（PCA）</div>
        
        <div class="search-wrap" id="search-wrap">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
                <i class="icon icon-lg icon-chevron-left"></i>
            </a>
            <input type="text" id="key" class="search-input" autocomplete="off" placeholder="输入感兴趣的关键字">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="search">
                <i class="icon icon-lg icon-search"></i>
            </a>
        </div>
        
        
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menuShare">
            <i class="icon icon-lg icon-share-alt"></i>
        </a>
        
    </div>
</header>
<header class="content-header post-header">

    <div class="container fade-scale">
        <h1 class="title">主成分分析（PCA）</h1>
        <h5 class="subtitle">
            
                <time datetime="2019-06-04T15:10:06.000Z" itemprop="datePublished" class="page-time">
  2019-06-04
</time>


	<ul class="article-category-list"><li class="article-category-list-item"><a class="article-category-list-link" href="../../../../categories/学习笔记/">学习笔记</a></li></ul>

            
        </h5>
    </div>

    


</header>


<div class="container body-wrap">
    
    <aside class="post-widget">
        <nav class="post-toc-wrap post-toc-shrink" id="post-toc">
            <h4>TOC</h4>
            <ol class="post-toc"><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#1-主成分分析"><span class="post-toc-text">1. 主成分分析</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#2-在NumPy中实现PCA"><span class="post-toc-text">2. 在NumPy中实现PCA</span></a></li></ol>
        </nav>
    </aside>


<article id="post-pca" class="post-article article-type-post fade" itemprop="blogPost">

    <div class="post-card">
        <h1 class="post-card-title">主成分分析（PCA）</h1>
        <div class="post-meta">
            
            <time class="post-time" title="2019-06-04 23:10:06" datetime="2019-06-04T15:10:06.000Z" itemprop="datePublished">


2019-06-04

 23:10:06 

</time>

            
	<ul class="article-category-list">作者：吴光生</ul>



            
	<ul class="article-category-list"><li class="article-category-list-item"><a class="article-category-list-link" href="../../../../categories/学习笔记/">学习笔记</a></li></ul>



            
            
<span id="busuanzi_container_page_pv" title="文章总阅读量" style="display:none">
    <i class="icon icon-eye icon-pr"></i><span id="busuanzi_value_page_pv"></span>
</span>


            
        </div>
        <div class="post-content" id="post-content" itemprop="postContent">
            <h2 id="1-主成分分析"><a href="#1-主成分分析" class="headerlink" title="1. 主成分分析"></a>1. 主成分分析</h2><p>优点：降低数据的复杂性，识别最重要的多个特征。</p>
<p>缺点：不一定需要，且可能损失有用信息。</p>
<p>使用数据类型：数值型数据</p>
 <a id="more"></a>
<h2 id="2-在NumPy中实现PCA"><a href="#2-在NumPy中实现PCA" class="headerlink" title="2. 在NumPy中实现PCA"></a>2. 在NumPy中实现PCA</h2><p>将数据转换成前K个主成分的伪码：</p>
<p>去除平均值（让样本矩阵中心化，即每一个维度减去该维度的均值，使每一维度上的均值为0）</p>
<p>计算协方差矩阵</p>
<p>计算协方差矩阵的特征值和特征向量</p>
<p>将特征值从大到小排序</p>
<p>保留最上面的K个特征向量</p>
<p>将数据转换到上述K个特征向量构建的新空间中</p>
<p>补充阅读：协方差矩阵</p>
<p>（1）一个维度上方差的定义：</p>
<script type="math/tex; mode=display">
var(X)=\frac{\sum_{i=1}^{n}(X_{i}-{\bar{X}})(X_{i}-{\bar{X}})}{n-1}</script><p>（2）协方差的定义：</p>
<script type="math/tex; mode=display">
cov(X,Y)=\frac{\sum_{i=1}^{n}(X_{i}-{\bar{X}})(Y_{i}-{\bar{Y}})}{n-1}</script><p>方差是协方差的一个特例，X与其自身的协方差就是X的方差。</p>
<p>分母为n-1是因为随机变量的数学期望未知，以样本均值代替，自由度减一。</p>
<p>协方差就是定义了两个维度之间的相关性，即这个样本的两个维度之间有没有关系。</p>
<p>协方差为0，证明这两个维度之间没有关系；协方差为正，两个维度正相关；协方差为负，两个维度负相关。</p>
<p>（3）协方差矩阵：</p>
<p>对n个维度，任意两个维度都计算一个协方差，组成矩阵。</p>
<script type="math/tex; mode=display">
C_{n \times n}=( c_{i,j}, c_{i,j}=cov(Dim_{i},Dim_{j}))</script><p>直观地，对于一个含有x，y，z三个维度的样本，协方差矩阵如下：</p>
<script type="math/tex; mode=display">
C=\begin{pmatrix}
cov(x,x) & cov(x,y) & cov(x,z)\\ 
cov(y,x) & cov(y,y) & cov(y,z)\\ 
cov(z,x) & cov(z,y) & cov(z,z)
\end{pmatrix}</script><p>可以看出，对角线表示了样本在各个维度上的方差，其他元素表示不同维度两两之间的相关性。</p>
<p>例：</p>
<p>假设原始数据为5个样本，每个样本有2个特征x和y。矩阵是：</p>
<script type="math/tex; mode=display">
Data =
\begin{bmatrix}
1 & -1\\ 
1 & 1\\ 
2 & 1\\ 
2 & 2\\ 
4 & 2
\end{bmatrix}</script><p>第一步，样本矩阵中心化（计算每个维度的均值，所有样本都减去均值）</p>
<p>维度x的均值为2，维度y的均值为1。</p>
<p>各维度去均值后，矩阵是：</p>
<script type="math/tex; mode=display">
DataAdjust = 
\begin{bmatrix}
-1 & -2\\ 
-1 & 0\\ 
0 & 0\\ 
0 & 1\\ 
2 & 1
\end{bmatrix}</script><p>这时，两个维度上的均值都为0。</p>
<p>第二步，计算协方差矩阵</p>
<p>协方差矩阵：</p>
<script type="math/tex; mode=display">
\begin{align*}
C &=
\begin{bmatrix}
cov(x,x) & cov(x,y)\\ 
cov(y,x) & cov(y,y)
\end{bmatrix}\\
&=
\begin{bmatrix}
\frac{(-1) \times (-1) + (-1) \times (-1) + 0 \times 0 + 0 \times 0 + 2 \times 2}{4} & 
\frac{(-1) \times (-2) + (-1) \times (0) + 0 \times 0 + 0 \times 1 + 2 \times 1}{4}\\ 
\frac{(-2) \times (-1) + (0) \times (-1) + 0 \times 0 + 1 \times 0 + 1 \times 2}{4}  & 
\frac{(-2) \times (-2) + (0) \times (0) + 0 \times 0 + 1 \times 1 + 1 \times 1}{4}
\end{bmatrix}\\
&=
\begin{bmatrix}
1.5 & 1.0\\ 
1.0 & 1.5
\end{bmatrix}
\end{align*}</script><p>第三步，计算协方差矩阵的特征值和特征向量</p>
<script type="math/tex; mode=display">
eigenValues=\begin{pmatrix}
2.5 & 0.5
\end{pmatrix}</script><script type="math/tex; mode=display">
eigenVectors=\begin{pmatrix}
0.70710678 & -0.70710678\\
0.70710678 & 0.70710678
\end{pmatrix}</script><p>特征值2.5对应的特征向量是eigenVectors的第1列：</p>
<script type="math/tex; mode=display">
\begin{pmatrix}
0.70710678\\
0.70710678
\end{pmatrix}</script><p>特征值0.5对应的特征向量是eigenVectors的第2列：</p>
<script type="math/tex; mode=display">
\begin{pmatrix}
-0.70710678\\
0.70710678
\end{pmatrix}</script><p>第四步，将特征值按照从大到小的顺序排列，选择其中最大的k个，然后将其对应的k个特征向量分别作为列向量组成特征向量矩阵</p>
<p>这里特征值只有2个，我们选取最大的那个2.5，对应的特征向量是：</p>
<script type="math/tex; mode=display">
\begin{pmatrix}0.70710678\\0.70710678\end{pmatrix}</script><p>第五步，将样本点投影到选取的特征向量上。</p>
<p>假设样本数为m，特征数为n，减去均值后的样本矩阵为DataAdjust(m×n)，协方差矩阵为C(n×n)，选取的k个特征向量组成的矩阵为TopEigenVectors(n×k)，那么投影后的低维数据LowDimData为：</p>
<script type="math/tex; mode=display">
LowDimData_{m\times k}=DataAdjust_{m \times n} \times TopEigenVectors_{n \times k}</script><p>这里是</p>
<script type="math/tex; mode=display">
LowDimData=
\begin{bmatrix}
-1 & -2\\ 
-1 & 0\\ 
0 & 0\\ 
0 & 1\\ 
2 & 1
\end{bmatrix}
 \times 
\begin{pmatrix}
0.70710678\\
0.70710678
\end{pmatrix}
=
\begin{bmatrix}
-2.12132034\\ 
-0.70710678\\ 
0\\ 
0.70710678\\ 
2.12132034
\end{bmatrix}</script><p>这样就将原始样本的n维（这个例子n=2）特征变成了k维（这个例子k=1），这k维就是原始特征在k维上的投影。</p>
<p>第六步，查看重构之后的数据，用于调试（假设K取值为n，重构回去的数据reconMat应该与原始数据Data重合）</p>
<script type="math/tex; mode=display">
reconMat = (LowDimData * TopEigenVectors.T) + meanVals</script><p>程序清单 PCA算法</p>
<pre><code class="lang-python">from numpy import *
import matplotlib
import matplotlib.pyplot as plt

def loadDataSet(fileName, delim=&#39;\t&#39;):
    fr = open(fileName)
    stringArr = [line.strip().split(delim) for line in fr.readlines()]
    datArr = [list(map(float,line)) for line in stringArr]
    # python3 needs list()
    return mat(datArr)

def pca(dataMat, topNfeat=9999999):
    meanVals = mean(dataMat, axis=0)
    dataAdjust = dataMat - meanVals #remove mean
    covMat = cov(dataAdjust, rowvar=0)
    eigVals,eigVects = linalg.eig(mat(covMat))
    eigValInd = argsort(eigVals)            #sort, sort goes smallest to largest
    eigValInd = eigValInd[:-(topNfeat+1):-1]  #cut off unwanted dimensions
    topEigVects = eigVects[:,eigValInd]       #reorganize eig vects largest to smallest
    lowDimDataMat = dataAdjust * topEigVects#transform data into new dimensions
    reconMat = (lowDimDataMat * topEigVects.T) + meanVals
    return lowDimDataMat, reconMat

dataMat = loadDataSet(&#39;testSet.txt&#39;)
lowDimDataMat, reconMat = pca(dataMat, 1)

fig = plt.figure()
ax = fig.add_subplot(111)
ax.scatter(dataMat[:,0].flatten().A[0],  dataMat[:,1].flatten().A[0], marker=&#39;^&#39;, s=90)
ax.scatter(reconMat[:,0].flatten().A[0], reconMat[:,1].flatten().A[0], marker=&#39;o&#39;, s=50, c=&#39;red&#39;)
plt.show()
</code></pre>
<p>运行结果如图1：<br><figure class="image-bubble">
                <div class="img-lightbox">
                    <div class="overlay"></div>
                    <img src="/assets/pca/Figure_1.png" alt title>
                </div>
                <div class="image-caption"></div>
            </figure></p>
<p><center> <font size="2" color="gray">图1 原始数据集(三角形)及第一主成分(圆形)</font>  </center><br>用到的数据集<a href="/assets/pca/testSet.txt">testSet.txt</a></p>
<p><strong>参考文献：</strong></p>
<p>[1]  (美) Harrington Peter著.  机器学习实战[M]. 李锐, 李鹏, 曲亚东, 王斌, 译.  北京: 人民邮电出版社, 2013.</p>

        </div>

        <blockquote class="post-copyright">
    
    <div class="content">
        
<span class="post-time">
    最后更新时间：<time datetime="2019-06-04T16:01:38.304Z" itemprop="dateUpdated">2019-06-05 00:01:38</time>
</span><br>


        
        	本文作者：吴光生  <br>本文链接：<a href target="_blank" rel="external">https://wgs666.github.io/2019/06/04/pca/</a><br>转载请注明作者及出处，谢谢！
        
    </div>
    
    <footer>
        <a href="https://wgs666.github.io">
            <img src="../../../../img/wgs.jpg" alt="Guangsheng Wu <br>吴光生">
            Guangsheng Wu <br>吴光生
        </a>
    </footer>
</blockquote>

        
<div class="page-reward">
    <a id="rewardBtn" href="javascript:;" class="page-reward-btn waves-effect waves-circle waves-light">赏</a>
</div>



        <div class="post-footer">
            
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="../../../../tags/机器学习/">机器学习</a></li></ul>


            
<div class="page-share-wrap">
    

<div class="page-share" id="pageShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=https://wgs666.github.io/2019/06/04/pca/&title=《主成分分析（PCA）》 — 路漫漫其修远兮，吾将上下而求索&pic=https://wgs666.github.io/img/wgs.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=https://wgs666.github.io/2019/06/04/pca/&title=《主成分分析（PCA）》 — 路漫漫其修远兮，吾将上下而求索&source=1. 主成分分析优点：降低数据的复杂性，识别最重要的多个特征。
缺点：不一定需要，且可能损失有用信息。
使用数据类型：数值型数据" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https://wgs666.github.io/2019/06/04/pca/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《主成分分析（PCA）》 — 路漫漫其修远兮，吾将上下而求索&url=https://wgs666.github.io/2019/06/04/pca/&via=https://wgs666.github.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=https://wgs666.github.io/2019/06/04/pca/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>



    <a href="javascript:;" id="shareFab" class="page-share-fab waves-effect waves-circle">
        <i class="icon icon-share-alt icon-lg"></i>
    </a>
</div>



        </div>
    </div>

    
<nav class="post-nav flex-row flex-justify-between flex-row-reverse">
  

  
    <div class="waves-block waves-effect next">
      <a href="../../03/first-blog/" id="post-next" class="post-nav-link">
        <div class="tips">Next <i class="icon icon-angle-right icon-lg icon-pl"></i></div>
        <h4 class="title">first-blog</h4>
      </a>
    </div>
  
</nav>



    



















    <section class="comments" id="comments">
        <div id="gitalk-container"></div>
        <link rel="stylesheet" href="https://unpkg.com/gitalk/dist/gitalk.css">
        <script src="https://unpkg.com/gitalk/dist/gitalk.min.js"></script>
        <script>
            var id = location.pathname
            if (location.pathname.length > 50) {
              id = location.pathname.replace(/\/\d+\/\d+\/\d+\//, '').replace('/', '').substring(0, 50)
            }
            const gitalk = new Gitalk({
              clientID: '83437958b93c1923bb8c',
              clientSecret: '5e77df83970d9528d9e3216146a2f13ec6d01c50',
              repo: 'hexoBlogComments',
              owner: 'wgs666',
              admin: ['wgs666'],
              id: id,      // Ensure uniqueness and length less than 50
              title: document.title.split('|')[0],
              distractionFreeMode: false  // Facebook-like distraction free mode
            })
            gitalk.render('gitalk-container')
        </script>
    </section>



</article>

<div id="reward" class="page-modal reward-lay">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <h3 class="reward-title">
        <i class="icon icon-quote-left"></i>
        感谢支持！
        <i class="icon icon-quote-right"></i>
    </h3>
    <div class="reward-content">
        
        <div class="reward-code">
            <img id="rewardCode" src="../../../../img/wechat.png" alt="打赏二维码">
        </div>
        
        <label class="reward-toggle">
            <input id="rewardToggle" type="checkbox" class="reward-toggle-check" data-wechat="../../../../img/wechat.png" data-alipay="../../../../img/alipay.png">
            <div class="reward-toggle-ctrol">
                <span class="reward-toggle-item wechat">微信</span>
                <span class="reward-toggle-item switch">切换</span>
                <span class="reward-toggle-item alipay">支付宝</span>
            </div>
        </label>
        
    </div>
</div>



</div>

        <footer class="footer">
    <div class="top">
        
<p>
    <span id="busuanzi_container_site_uv" style="display:none">
        站点总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style="display:none">
        站点总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


            <p>
                
                    <span>
                        <a href="../../../../atom.xml" target="_blank" class="rss" title="rss">
                            <i class="icon icon-lg icon-rss"></i>
                        </a>
                    </span>
                    
                        <span>
                            博客内容遵循 <a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">知识共享 署名 - 非商业性 - 相同方式共享 4.0 国际协议</a>
                        </span>
            </p>
    </div>
    <div class="bottom">
        <p>
            <span>
                Guangsheng Wu <br>吴光生 &copy;
                    
                                2019
            </span>
            <span>
                
                        Power by
                        <a href="http://hexo.io/" target="_blank">Hexo</a> Theme
                        <a href="https://github.com/abelsu7/hexo-theme-indigo-plus" target="_blank">indigo plus</a>
                        <p>Hosted by <a href="https://coding.net/pages" style="font-weight: bold">Coding Pages</a></p>
            </span>
        </p>
        <p>
         <script type="text/javascript" src="//js.users.51.la/20081489.js"></script>
        </p>
    </div>
</footer>

    </main>
    <div class="mask" id="mask"></div>
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>
<a href="javascript:;" id="gobottom" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-comments"></span></a>



<div class="global-share" id="globalShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=https://wgs666.github.io/2019/06/04/pca/&title=《主成分分析（PCA）》 — 路漫漫其修远兮，吾将上下而求索&pic=https://wgs666.github.io/img/wgs.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=https://wgs666.github.io/2019/06/04/pca/&title=《主成分分析（PCA）》 — 路漫漫其修远兮，吾将上下而求索&source=1. 主成分分析优点：降低数据的复杂性，识别最重要的多个特征。
缺点：不一定需要，且可能损失有用信息。
使用数据类型：数值型数据" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https://wgs666.github.io/2019/06/04/pca/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《主成分分析（PCA）》 — 路漫漫其修远兮，吾将上下而求索&url=https://wgs666.github.io/2019/06/04/pca/&via=https://wgs666.github.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=https://wgs666.github.io/2019/06/04/pca/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>


<div class="page-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <img src="" alt="微信分享二维码">
</div>




    <script src="//cdn.jsdelivr.net/npm/node-waves@0.7.6/src/js/waves.min.js"></script>
<script>
var BLOG = { ROOT: '/', SHARE: true, REWARD: true };


</script>

<script src="../../../../js/main.min.js?v=1.7.2"></script>


<div class="search-panel" id="search-panel">
    <ul class="search-result" id="search-result"></ul>
</div>
<template id="search-tpl">
<li class="item">
    <a href="{path}" class="waves-block waves-effect">
        <div class="title ellipsis" title="{title}">{title}</div>
        <div class="flex-row flex-middle">
            <div class="tags ellipsis">
                {tags}
            </div>
            <time class="flex-col time">{date}</time>
        </div>
    </a>
</li>
</template>

<script src="../../../../js/search.min.js?v=1.7.2" async></script>



<!-- mathjax config similar to math.stackexchange -->

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
    tex2jax: {
        inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
        processEscapes: true,
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
    }
});

MathJax.Hub.Queue(function() {
    var all = MathJax.Hub.getAllJax(), i;
    for(i=0; i < all.length; i += 1) {
        all[i].SourceElement().parentNode.className += ' has-jax';
    }
});
</script>

<script async src="//cdn.jsdelivr.net/npm/mathjax@2.7.5/MathJax.js?config=TeX-MML-AM_CHTML"></script>
<!-- <script async src="//cdn.bootcss.com/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML" async></script> -->
<!-- <script async src="//cdn.bootcss.com/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" async></script> -->




<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>




<script src="/js/prism.js"></script>
<script src="/js/prism-vim.js"></script>
   
</body>
</html>
